package cn.mldn.microboot.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * description:
 * Created by gy on 2017/8/23.
 */
@Component
public class MySchedule {

    private Logger log = LoggerFactory.getLogger(getClass());

    @Scheduled(fixedRate = 2000)//2秒执行一次
    public void runJobA() throws InterruptedException {
        Thread.sleep(5000L);
        log.info("MyTaskA - 间隔调度" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }

    @Scheduled(cron = "* * * * * ?")//每秒调用一次
    public void runJobB(){
        log.info("MyTaskB - 间隔调度" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

    }
}
